function proj_visuals

%task1 - waiting times
plot_task1;

%task2 - CLR and running times
plot_task2;           

plot_task3;

plot_task5;
%task3 - waiting times
% 
% generate_single_plot('task3/overall_waiting.result', 'Overall Average waiting time (sec) vs \rho, C = 100,000', ...
%                      '\rho', 'Overall Average waiting time (sec)', {'C=100,000'}, 'figure_task3_overall_waiting.eps');
%                  
% generate_single_plot('task3/cpu_waiting.result', 'CPU Average waiting time (sec) vs \rho, C = 100,000', ...
%                      '\rho', 'CPU Average waiting time (sec)', {'C=100,000'}, 'figure_task3_cpu_waiting.eps');                 
% 
% generate_single_plot('task3/io1_waiting.result', 'IO1 Average waiting time (sec) vs \rho, C = 100,000', ...
%                      '\rho', 'IO1 Average waiting time (sec)', {'C=100,000'}, 'figure_task3_io1_waiting.eps');
%                  
% generate_single_plot('task3/io2_waiting.result', 'IO2 Average waiting time (sec) vs \rho, C = 100,000', ...
%                      '\rho', 'IO2 Average waiting time (sec)', {'C=100,000'}, 'figure_task3_io2_waiting.eps');                 
% 
% generate_single_plot('task3/io3_waiting.result', 'IO3 Average waiting time (sec) vs \rho, C = 100,000', ...
%                      '\rho', 'IO3 Average waiting time (sec)', {'C=100,000'}, 'figure_task3_io3_waiting.eps');

                 
%task3 - clr

% generate_single_plot('task3/overall_clr.result', 'Overall CLR vs \rho, C = 100,000', ...
%                      '\rho', 'Overall CLR', {'C=100,000'}, 'figure_task3_overall_clr.eps');
%                  
% generate_single_plot('task3/cpu_clr.result', 'CPU CLR vs \rho, C = 100,000', ...
%                      '\rho', 'CPU CLR', {'C=100,000'}, 'figure_task3_cpu_clr.eps');                 
%                  
% generate_single_plot('task3/io1_clr.result', 'IO 1 CLR vs \rho, C = 100,000', ...
%                      '\rho', 'IO 1 CLR', {'C=100,000'}, 'figure_task3_io1_clr.eps');                 
% 
% generate_single_plot('task3/io2_clr.result', 'IO 2 CLR vs \rho, C = 100,000', ...
%                      '\rho', 'IO 2 CLR', {'C=100,000'}, 'figure_task3_io2_clr.eps');                 
%                  
% generate_single_plot('task3/io3_clr.result', 'IO3  CLR vs \rho, C = 100,000', ...
%                      '\rho', 'IO 3 CLR', {'C=100,000'}, 'figure_task3_io3_clr.eps');                                  
                 
end

function plot_task5

[databarcpu, confcpu] = generate_single_plot('task3/cpu_visits', 'Average CPU visits vs \rho, C = 100,000', ...
                      '\rho', 'Average CPU visits', {'C=100,000'},...
                      'task5/cpu_visits.eps', false);

data = load('task3/io1_visits');
databario1 = data(:, 1);
conf = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databario1, 'rs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar, conf);

data = load('task3/io2_visits');
databario2 = data(:, 1);
conf = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databario2, 'ms-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar, conf);

data = load('task3/io3_visits');
databario3 = data(:, 1);
conf = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databario3, 'ks-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar, conf);

hTitle = title('Average number of visits vs \rho');
hXLabel = xlabel('\rho');
hYLabel = ylabel('Average number of visits');
hLegend = legend({'IO1', 'IO2', 'IO3'}, 'Location', 'Best');

set(gca,'FontName','Helvetica')

set([hTitle, hXLabel, hYLabel, hLegend], 'FontName', 'Helvetica', 'FontWeight', 'bold');
set([hLegend, gca], 'FontSize', 10);
set([hXLabel, hYLabel], 'FontSize', 12)
set(hTitle,'FontSize', 14, 'FontWeight', 'bold');
grid on
set(gca, ...
    'Box'         , 'off'     , ...
    'TickDir'     , 'out'     , ...
    'TickLength'  , [.02 .02] , ...
    'XMinorTick'  , 'on'      , ...
    'YMinorTick'  , 'on'      , ...
    'YGrid'       , 'on'      , ...
    'XColor'      , [.3 .3 .3], ...
    'YColor'      , [.3 .3 .3], ...
    'LineWidth'   , 1         );
axis fill
set(gcf, 'PaperPositionMode', 'auto');
print('-depsc2', 'task5/io_visits.eps');
close;

figure(1);
plot(0.05:0.1:0.95, databarcpu, 'gs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
plot(0.05:0.1:0.95, databario1, 'rs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
plot(0.05:0.1:0.95, databario2, 'ms-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
plot(0.05:0.1:0.95, databario3, 'ks-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;

hTitle = title('Average number of visits vs \rho');
hXLabel = xlabel('\rho');
hYLabel = ylabel('Average number of visits');
hLegend = legend({'CPU', 'IO1', 'IO2', 'IO3'}, 'Location', 'Best');

set(gca,'FontName','Helvetica')

set([hTitle, hXLabel, hYLabel, hLegend], 'FontName', 'Helvetica', 'FontWeight', 'bold');
set([hLegend, gca], 'FontSize', 10);
set([hXLabel, hYLabel], 'FontSize', 12)
set(hTitle,'FontSize', 14, 'FontWeight', 'bold');
grid on
set(gca, ...
    'Box'         , 'off'     , ...
    'TickDir'     , 'out'     , ...
    'TickLength'  , [.02 .02] , ...
    'XMinorTick'  , 'on'      , ...
    'YMinorTick'  , 'on'      , ...
    'YGrid'       , 'on'      , ...
    'XColor'      , [.3 .3 .3], ...
    'YColor'      , [.3 .3 .3], ...
    'LineWidth'   , 1         );
axis fill
set(gcf, 'PaperPositionMode', 'auto');
print('-depsc2', 'task5/all_visits.eps');
close;
end

function plot_task3


%CLR
figure(1);
data = load('task3/overall_clr');
databar = data(:, 1);
conf = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databar, 'rs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar, conf);

data = load('task3/cpu_clr');
databar = data(:, 1);
conf = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databar, 'gs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar, conf);

data = load('task3/io1_clr');
databar = data(:, 1);
conf = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databar, 'bs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar, conf);

data = load('task3/io2_clr');
databar = data(:, 1);
conf = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databar, 'ms-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar, conf);

data = load('task3/io3_clr');
databar = data(:, 1);
conf = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databar, 'ks-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar, conf);

hTitle = title('CLR vs \rho');
hXLabel = xlabel('\rho');
hYLabel = ylabel('CLR');
hLegend = legend({'Overall', 'CPU','IO1', 'IO2', 'IO3'}, 'Location', 'Best');

set(gca,'FontName','Helvetica')

set([hTitle, hXLabel, hYLabel, hLegend], 'FontName', 'Helvetica', 'FontWeight', 'bold');
set([hLegend, gca], 'FontSize', 10);
set([hXLabel, hYLabel], 'FontSize', 12)
set(hTitle,'FontSize', 14, 'FontWeight', 'bold');
grid on
set(gca, ...
    'Box'         , 'off'     , ...
    'TickDir'     , 'out'     , ...
    'TickLength'  , [.02 .02] , ...
    'XMinorTick'  , 'on'      , ...
    'YMinorTick'  , 'on'      , ...
    'YGrid'       , 'on'      , ...
    'XColor'      , [.3 .3 .3], ...
    'YColor'      , [.3 .3 .3], ...
    'LineWidth'   , 1         );
axis fill
set(gcf, 'PaperPositionMode', 'auto');
print('-depsc2', 'task3/clr.eps');
close;



%WAITING TIME
figure(1);
data = load('task3/overall_waiting');
databar = data(:, 1);
conf = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databar, 'rs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
errorbar(0.05:0.1:0.95, databar, conf);


data = load('task3/cpu_waiting');
databar = data(:, 1);
conf = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databar, 'gs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
errorbar(0.05:0.1:0.95, databar, conf);

data = load('task3/io1_waiting');
databar = data(:, 1);
conf = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databar, 'bs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
errorbar(0.05:0.1:0.95, databar, conf);

data = load('task3/io2_waiting');
databar = data(:, 1);
conf = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databar, 'ms-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
errorbar(0.05:0.1:0.95, databar, conf);

data = load('task3/io3_waiting');
databar = data(:, 1);
conf = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databar, 'ys-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
errorbar(0.05:0.1:0.95, databar, conf);


hTitle = title('Average waiting time(sec) vs \rho');
hXLabel = xlabel('\rho');
hYLabel = ylabel('Average waiting time(sec)');
hLegend = legend({'Overall', 'CI', 'CPU', 'CI','IO1', 'CI', 'IO2', 'CI', 'IO3', 'CI'}, 'Location', 'Best');

set(gca,'FontName','Helvetica')

set([hTitle, hXLabel, hYLabel, hLegend], 'FontName', 'Helvetica', 'FontWeight', 'bold');
set([hLegend, gca], 'FontSize', 10);
set([hXLabel, hYLabel], 'FontSize', 12)
set(hTitle,'FontSize', 14, 'FontWeight', 'bold');
grid on
set(gca, ...
    'Box'         , 'off'     , ...
    'TickDir'     , 'out'     , ...
    'TickLength'  , [.02 .02] , ...
    'XMinorTick'  , 'on'      , ...
    'YMinorTick'  , 'on'      , ...
    'YGrid'       , 'on'      , ...
    'XColor'      , [.3 .3 .3], ...
    'YColor'      , [.3 .3 .3], ...
    'LineWidth'   , 1         );
axis fill
set(gcf, 'PaperPositionMode', 'auto');
print('-depsc2', 'task3/waiting.eps');
close;

%task3 - waiting times
% 
%generate_single_plot('task3/overall_waiting.result', 'Overall Average waiting time (sec) vs \rho, C = 100,000', ...
%                      '\rho', 'Overall Average waiting time (sec)', {'C=100,000'}, 'figure_task3_overall_waiting.eps');
%                  
% generate_single_plot('task3/cpu_waiting.result', 'CPU Average waiting time (sec) vs \rho, C = 100,000', ...
%                      '\rho', 'CPU Average waiting time (sec)', {'C=100,000'}, 'figure_task3_cpu_waiting.eps');                 
% 
% generate_single_plot('task3/io1_waiting.result', 'IO1 Average waiting time (sec) vs \rho, C = 100,000', ...
%                      '\rho', 'IO1 Average waiting time (sec)', {'C=100,000'}, 'figure_task3_io1_waiting.eps');
%                  
% generate_single_plot('task3/io2_waiting.result', 'IO2 Average waiting time (sec) vs \rho, C = 100,000', ...
%                      '\rho', 'IO2 Average waiting time (sec)', {'C=100,000'}, 'figure_task3_io2_waiting.eps');                 
% 
% generate_single_plot('task3/io3_waiting.result', 'IO3 Average waiting time (sec) vs \rho, C = 100,000', ...
%                      '\rho', 'IO3 Average waiting time (sec)', {'C=100,000'}, 'figure_task3_io3_waiting.eps');

                 
%task3 - clr

% generate_single_plot('task3/overall_clr.result', 'Overall CLR vs \rho, C = 100,000', ...
%                      '\rho', 'Overall CLR', {'C=100,000'}, 'figure_task3_overall_clr.eps');
%                  
% generate_single_plot('task3/cpu_clr.result', 'CPU CLR vs \rho, C = 100,000', ...
%                      '\rho', 'CPU CLR', {'C=100,000'}, 'figure_task3_cpu_clr.eps');                 
%                  
% generate_single_plot('task3/io1_clr.result', 'IO 1 CLR vs \rho, C = 100,000', ...
%                      '\rho', 'IO 1 CLR', {'C=100,000'}, 'figure_task3_io1_clr.eps');                 
% 
% generate_single_plot('task3/io2_clr.result', 'IO 2 CLR vs \rho, C = 100,000', ...
%                      '\rho', 'IO 2 CLR', {'C=100,000'}, 'figure_task3_io2_clr.eps');                 
%                  
% generate_single_plot('task3/io3_clr.result', 'IO3  CLR vs \rho, C = 100,000', ...
%                      '\rho', 'IO 3 CLR', {'C=100,000'},
%                      'figure_task3_io3_clr.eps');      

end

function plot_task1

%FCFS

[databar1, conf1] = generate_single_plot('task1/waiting.fcfs', 'Average waiting time (FCFS)(sec) vs \rho, C = 100,000', ...
                     '\rho', 'Average waiting time (FCFS)(sec)', {'C=100,000'}, 'task1/figure_task1_waiting_fcfs.eps', true);

%LCFS

[databar2, conf2] = generate_single_plot('task1/waiting.lcfs', 'Average waiting time (LCFS)(sec) vs \rho, C = 100,000', ...
                     '\rho', 'Average waiting time (LCFS)(sec)', {'C=100,000'}, 'task1/figure_task1_waiting_lcfs.eps', true);
           
%SJF

[databar3, conf3] = generate_single_plot('task1/waiting.sjf', 'Average waiting time (SJF)(sec) vs \rho, C = 100,000', ...
                     '\rho', 'Average waiting time (SJF)(sec)', {'C=100,000'}, 'task1/figure_task1_waiting_sjf.eps', true);                 

                 
%PRIORITY NP OVERALL AND QUEUE WISE
[databar4, conf4] = generate_single_plot('task1/prioritynp/waiting.prioritynp', 'Average waiting time (Pri-NP)(sec) vs \rho, C = 100,000', ...
                     '\rho', 'Average waiting time (Pri-NP)(sec)', {'C=100,000'}, 'task1/figure_task1_waiting_prinp.eps', true);                 

data = load('task1/prioritynp/waiting_queue0.prioritynp');
databar = data(:, 1);
conf = data(:, 3) - data(:, 2);

figure(1);
plot(0.05:0.1:0.95, databar, 'rs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
errorbar(0.05:0.1:0.95, databar, conf);

data = load('task1/prioritynp/waiting_queue1.prioritynp');
databar = data(:, 1);
conf = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databar, 'gs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
errorbar(0.05:0.1:0.95, databar, conf);

data = load('task1/prioritynp/waiting_queue2.prioritynp');
databar = data(:, 1);
conf = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databar, 'bs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
errorbar(0.05:0.1:0.95, databar, conf);

data = load('task1/prioritynp/waiting_queue3.prioritynp');
databar = data(:, 1);
conf = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databar, 'ms-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
errorbar(0.05:0.1:0.95, databar, conf);
grid on;

hTitle = title('Average waiting time (Pri-NP) Queues(sec) vs \rho');
hXLabel = xlabel('\rho');
hYLabel = ylabel('Average waiting time (Pri-NP) Queues(sec)');
hLegend = legend({'Queue 1', 'CI', 'Queue 2', 'CI', 'Queue 3', 'CI', 'Queue 4', 'CI'}, 'Location', 'Best');

set(gca,'FontName','Helvetica')

set([hTitle, hXLabel, hYLabel, hLegend], 'FontName', 'Helvetica', 'FontWeight', 'bold');
set([hLegend, gca], 'FontSize', 10);
set([hXLabel, hYLabel], 'FontSize', 12)
set(hTitle,'FontSize', 14, 'FontWeight', 'bold');
grid on
set(gca, ...
    'Box'         , 'off'     , ...
    'TickDir'     , 'out'     , ...
    'TickLength'  , [.02 .02] , ...
    'XMinorTick'  , 'on'      , ...
    'YMinorTick'  , 'on'      , ...
    'YGrid'       , 'on'      , ...
    'XColor'      , [.3 .3 .3], ...
    'YColor'      , [.3 .3 .3], ...
    'LineWidth'   , 1         );
axis fill
set(gcf, 'PaperPositionMode', 'auto');
print('-depsc2', 'task1/waiting_prinp_queues.eps');
close;



%PRIORITY P OVERALL AND QUEUE WISE
[databar5, conf5] = generate_single_plot('task1/priorityp/waiting.priorityp', 'Average waiting time (Pri-P)(sec) vs \rho, C = 100,000', ...
                     '\rho', 'Average waiting time (Pri-P)(sec)', {'C=100,000'}, 'task1/figure_task1_waiting_prip.eps', true);                                  
          
data = load('task1/priorityp/waiting_queue0.priorityp');
databar = data(:, 1);
conf = data(:, 3) - data(:, 2);

figure(1);
plot(0.05:0.1:0.95, databar, 'rs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
errorbar(0.05:0.1:0.95, databar, conf);

data = load('task1/priorityp/waiting_queue1.priorityp');
databar = data(:, 1);
conf = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databar, 'gs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
errorbar(0.05:0.1:0.95, databar, conf);

data = load('task1/priorityp/waiting_queue2.priorityp');
databar = data(:, 1);
conf = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databar, 'bs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
errorbar(0.05:0.1:0.95, databar, conf);

data = load('task1/priorityp/waiting_queue3.priorityp');
databar = data(:, 1);
conf = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databar, 'ms-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
errorbar(0.05:0.1:0.95, databar, conf);
grid on;

hTitle = title('Average waiting time (Pri-P) Queues(sec) vs \rho');
hXLabel = xlabel('\rho');
hYLabel = ylabel('Average waiting time (Pri-P) Queues(sec)');
hLegend = legend({'Queue 1', 'CI', 'Queue 2', 'CI', 'Queue 3', 'CI', 'Queue 4', 'CI'}, 'Location', 'Best');

set(gca,'FontName','Helvetica')

set([hTitle, hXLabel, hYLabel, hLegend], 'FontName', 'Helvetica', 'FontWeight', 'bold');
set([hLegend, gca], 'FontSize', 10);
set([hXLabel, hYLabel], 'FontSize', 12)
set(hTitle,'FontSize', 14, 'FontWeight', 'bold');
grid on
set(gca, ...
    'Box'         , 'off'     , ...
    'TickDir'     , 'out'     , ...
    'TickLength'  , [.02 .02] , ...
    'XMinorTick'  , 'on'      , ...
    'YMinorTick'  , 'on'      , ...
    'YGrid'       , 'on'      , ...
    'XColor'      , [.3 .3 .3], ...
    'YColor'      , [.3 .3 .3], ...
    'LineWidth'   , 1         );
axis fill
set(gcf, 'PaperPositionMode', 'auto');
print('-depsc2', 'task1/waiting_prip_queues.eps');
close;                                 
 


%ALL DISCIPLINES                                
                 
figure(1);
plot(0.05:0.1:0.95, databar1, 'rs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
errorbar(0.05:0.1:0.95, databar1, conf1);

plot(0.05:0.1:0.95, databar2, 'gs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
errorbar(0.05:0.1:0.95, databar2, conf2);

plot(0.05:0.1:0.95, databar3, 'bs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
errorbar(0.05:0.1:0.95, databar3, conf3);

plot(0.05:0.1:0.95, databar4, 'ks-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
errorbar(0.05:0.1:0.95, databar4, conf4);

plot(0.05:0.1:0.95, databar5, 'ms-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
errorbar(0.05:0.1:0.95, databar5, conf5);
grid on;

hTitle = title('Average waiting time(sec) vs \rho');
hXLabel = xlabel('\rho');
hYLabel = ylabel('Average waiting time(sec)');
hLegend = legend({'FCFS','CI','LCFS','CI','SJF','CI','PRI-NP','CI','PRI-P','CI'}, 'Location', 'Best');

set(gca,'FontName','Helvetica')

set([hTitle, hXLabel, hYLabel, hLegend], 'FontName', 'Helvetica', 'FontWeight', 'bold');
set([hLegend, gca], 'FontSize', 10);
set([hXLabel, hYLabel], 'FontSize', 12)
set(hTitle,'FontSize', 14, 'FontWeight', 'bold');
grid on
set(gca, ...
    'Box'         , 'off'     , ...
    'TickDir'     , 'out'     , ...
    'TickLength'  , [.02 .02] , ...
    'XMinorTick'  , 'on'      , ...
    'YMinorTick'  , 'on'      , ...
    'YGrid'       , 'on'      , ...
    'XColor'      , [.3 .3 .3], ...
    'YColor'      , [.3 .3 .3], ...
    'LineWidth'   , 1         );
axis fill
set(gcf, 'PaperPositionMode', 'auto');
print('-depsc2', 'task1/waiting_all.eps');
close;

end

function plot_task2

%FCFS

[databar1, conf1] = generate_single_plot('task2/CLR.fcfs', 'Average CLR (FCFS) vs \rho, C = 100,000', ...
                     '\rho', 'Average CLR (FCFS)', {'C=100,000'}, 'task2/figure_task2_CLR_fcfs.eps', false);

%LCFS

[databar2, conf2] = generate_single_plot('task2/CLR.lcfs', 'Average CLR (LCFS) vs \rho, C = 100,000', ...
                     '\rho', 'Average CLR (LCFS)', {'C=100,000'}, 'task2/figure_task2_CLR_lcfs.eps', false);
           
%SJF

[databar3, conf3] = generate_single_plot('task2/CLR.sjf', 'Average CLR (SJF) vs \rho, C = 100,000', ...
                     '\rho', 'Average CLR (SJF)', {'C=100,000'}, 'task2/figure_task2_CLR_sjf.eps', false);                 

                 
%PRIORITY NP OVERALL 
[databar4, conf4] = generate_single_plot('task2/prioritynp/CLR.prioritynp', 'Average CLR (Pri-NP) vs \rho, C = 100,000', ...
                     '\rho', 'Average CLR (Pri-NP)', {'C=100,000'}, 'task2/figure_task2_CLR_prinp.eps', false);                 

plot_prioritynp_clr_queues;

%PRIORITY P OVERALL
[databar5, conf5] = generate_single_plot('task2/priorityp/CLR.priorityp', 'Average CLR (Pri-P) vs \rho, C = 100,000', ...
                     '\rho', 'Average CLR (Pri-P)', {'C=100,000'}, 'task2/figure_task2_CLR_prip.eps', false);                                  

plot_priorityp_clr_queues;

%ALL DISCIPLINES                                
                 
figure(1);
plot(0.05:0.1:0.95, databar1, 'rs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar1, conf1);

plot(0.05:0.1:0.95, databar2, 'gs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar2, conf2);

plot(0.05:0.1:0.95, databar3, 'bs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar3, conf3);

plot(0.05:0.1:0.95, databar4, 'ks-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar4, conf4);

plot(0.05:0.1:0.95, databar5, 'ms-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar5, conf5);
grid on;

hTitle = title('Average CLR vs \rho');
hXLabel = xlabel('\rho');
hYLabel = ylabel('Average CLR');
hLegend = legend({'FCFS','LCFS','SJF','PRI-NP','PRI-P'}, 'Location', 'Best');

set(gca,'FontName','Helvetica')

set([hTitle, hXLabel, hYLabel, hLegend], 'FontName', 'Helvetica', 'FontWeight', 'bold');
set([hLegend, gca], 'FontSize', 10);
set([hXLabel, hYLabel], 'FontSize', 12)
set(hTitle,'FontSize', 14, 'FontWeight', 'bold');
grid on
set(gca, ...
    'Box'         , 'off'     , ...
    'TickDir'     , 'out'     , ...
    'TickLength'  , [.02 .02] , ...
    'XMinorTick'  , 'on'      , ...
    'YMinorTick'  , 'on'      , ...
    'YGrid'       , 'on'      , ...
    'XColor'      , [.3 .3 .3], ...
    'YColor'      , [.3 .3 .3], ...
    'LineWidth'   , 1         );
axis fill
set(gcf, 'PaperPositionMode', 'auto');
print('-depsc2', 'task2/CLR_all.eps');
close;



%FCFS

[databar1, conf1] = generate_single_plot('task2/running.fcfs', 'Average running.time (30 runs) (FCFS)(sec) vs \rho, C = 100,000', ...
                     '\rho', 'Average running.time (30 runs) (FCFS)(sec)', {'C=100,000'}, 'task2/figure_task2_running_fcfs.eps', false);

%LCFS

[databar2, conf2] = generate_single_plot('task2/running.lcfs', 'Average running.time (30 runs) (LCFS)(sec) vs \rho, C = 100,000', ...
                     '\rho', 'Average running.time (30 runs) (LCFS)(sec)', {'C=100,000'}, 'task2/figure_task2_running_lcfs.eps', false);
           
%SJF

[databar3, conf3] = generate_single_plot('task2/running.sjf', 'Average running.time (30 runs) (SJF)(sec) vs \rho, C = 100,000', ...
                     '\rho', 'Average running.time (30 runs) (SJF)(sec)', {'C=100,000'}, 'task2/figure_task2_running_sjf.eps', false);                 

                 
%PRIORITY NP OVERALL 
[databar4, conf4] = generate_single_plot('task2/prioritynp/running.prioritynp', 'Average running.time (30 runs) (Pri-NP)(sec) vs \rho, C = 100,000', ...
                     '\rho', 'Average running.time (30 runs) (Pri-NP)(sec)', {'C=100,000'}, 'task2/figure_task2_running_prinp.eps', false);                 

%PRIORITY P OVERALL
[databar5, conf5] = generate_single_plot('task2/priorityp/running.priorityp', 'Average running.time (30 runs) (Pri-P)(sec) vs \rho, C = 100,000', ...
                     '\rho', 'Average running.time (30 runs) (Pri-P)(sec)', {'C=100,000'}, 'task2/figure_task2_running_prip.eps', false);                                  
          
%ALL DISCIPLINES                                
                 
figure(1);
plot(0.05:0.1:0.95, databar1, 'rs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar1, conf1);

plot(0.05:0.1:0.95, databar2, 'gs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar2, conf2);

plot(0.05:0.1:0.95, databar3, 'bs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar3, conf3);

plot(0.05:0.1:0.95, databar4, 'ks-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar4, conf4);

plot(0.05:0.1:0.95, databar5, 'ms-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar5, conf5);
grid on;

hTitle = title('Average running.time (30 runs)(sec) vs \rho');
hXLabel = xlabel('\rho');
hYLabel = ylabel('Average running.time (30 runs)');
hLegend = legend({'FCFS','LCFS','SJF','PRI-NP','PRI-P'}, 'Location', 'Best');

set(gca,'FontName','Helvetica')

set([hTitle, hXLabel, hYLabel, hLegend], 'FontName', 'Helvetica', 'FontWeight', 'bold');
set([hLegend, gca], 'FontSize', 10);
set([hXLabel, hYLabel], 'FontSize', 12)
set(hTitle,'FontSize', 14, 'FontWeight', 'bold');
grid on
set(gca, ...
    'Box'         , 'off'     , ...
    'TickDir'     , 'out'     , ...
    'TickLength'  , [.02 .02] , ...
    'XMinorTick'  , 'on'      , ...
    'YMinorTick'  , 'on'      , ...
    'YGrid'       , 'on'      , ...
    'XColor'      , [.3 .3 .3], ...
    'YColor'      , [.3 .3 .3], ...
    'LineWidth'   , 1         );
axis fill
set(gcf, 'PaperPositionMode', 'auto');
print('-depsc2', 'task2/running_all.eps');
close;

end


function [databar, conf_interval] = generate_single_plot(filename, ttl, xlbl, ylbl, lgnd, outputfilename, plotConfInterval)

figure(1);
data = load(filename);
databar = data(:, 1);
conf_interval = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databar, 'rs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
if (plotConfInterval)
    errorbar(0.05:0.1:0.95, databar, conf_interval);  
end
grid on;

hTitle = title(ttl);
hXLabel = xlabel(xlbl);
hYLabel = ylabel(ylbl);
hLegend = legend(lgnd, 'Location', 'Best');

set(gca,'FontName','Helvetica')

set([hTitle, hXLabel, hYLabel, hLegend], 'FontName', 'Helvetica', 'FontWeight', 'bold');
set([hLegend, gca], 'FontSize', 10);
set([hXLabel, hYLabel], 'FontSize', 12)
set(hTitle,'FontSize', 14, 'FontWeight', 'bold');
grid on
set(gca, ...
    'Box'         , 'off'     , ...
    'TickDir'     , 'out'     , ...
    'TickLength'  , [.02 .02] , ...
    'XMinorTick'  , 'on'      , ...
    'YMinorTick'  , 'on'      , ...
    'YGrid'       , 'on'      , ...
    'XColor'      , [.3 .3 .3], ...
    'YColor'      , [.3 .3 .3], ...
    'LineWidth'   , 1         );
axis fill
set(gcf, 'PaperPositionMode', 'auto');
print('-depsc2', outputfilename);
close;

end


function plot_prioritynp_clr_queues

figure(1);
data = load('task2/prioritynp/clr_queue0.prioritynp');
databar = data(:, 1);
conf_interval = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databar, 'rs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar, conf_interval);

data = load('task2/prioritynp/clr_queue1.prioritynp');
databar = data(:, 1);
conf_interval = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databar, 'gs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar, conf_interval);

data = load('task2/prioritynp/clr_queue2.prioritynp');
databar = data(:, 1);
conf_interval = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databar, 'ms-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar, conf_interval);

data = load('task2/prioritynp/clr_queue3.prioritynp');
databar = data(:, 1);
conf_interval = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databar, 'ks-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar, conf_interval);
grid on;

hTitle = title('Queue-wise CLR for Priority-NP vs \rho');
hXLabel = xlabel('\rho');
hYLabel = ylabel('CLR');
hLegend = legend({'Queue 0', 'Queue 1', 'Queue 2', 'Queue 3'}, 'Location', 'Best');

set(gca,'FontName','Helvetica')

set([hTitle, hXLabel, hYLabel, hLegend], 'FontName', 'Helvetica', 'FontWeight', 'bold');
set([hLegend, gca], 'FontSize', 10);
set([hXLabel, hYLabel], 'FontSize', 12)
set(hTitle,'FontSize', 14, 'FontWeight', 'bold');
grid on
set(gca, ...
    'Box'         , 'off'     , ...
    'TickDir'     , 'out'     , ...
    'TickLength'  , [.02 .02] , ...
    'XMinorTick'  , 'on'      , ...
    'YMinorTick'  , 'on'      , ...
    'YGrid'       , 'on'      , ...
    'XColor'      , [.3 .3 .3], ...
    'YColor'      , [.3 .3 .3], ...
    'LineWidth'   , 1         );
axis fill
set(gcf, 'PaperPositionMode', 'auto');
print('-depsc2', 'task2/CLR_queues_prioritynp.eps');
close;
end

function plot_priorityp_clr_queues

figure(1);
data = load('task2/priorityp/clr_queue0.priorityp');
databar = data(:, 1);
conf_interval = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databar, 'rs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar, conf_interval);

data = load('task2/priorityp/clr_queue1.priorityp');
databar = data(:, 1);
conf_interval = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databar, 'gs-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar, conf_interval);

data = load('task2/priorityp/clr_queue2.priorityp');
databar = data(:, 1);
conf_interval = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databar, 'ms-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar, conf_interval);

data = load('task2/priorityp/clr_queue3.priorityp');
databar = data(:, 1);
conf_interval = data(:, 3) - data(:, 2);

plot(0.05:0.1:0.95, databar, 'ks-', 'LineWidth', 2, 'MarkerSize', 1, 'MarkerFaceColor' , [.49 1 .63], 'MarkerEdgeColor', 'k'); hold on;
%errorbar(0.05:0.1:0.95, databar, conf_interval);
grid on;

hTitle = title('Queuewise CLR for Priority-P vs \rho');
hXLabel = xlabel('\rho');
hYLabel = ylabel('CLR');
hLegend = legend({'Queue 0', 'Queue 1', 'Queue 2', 'Queue 3' }, 'Location', 'Best');

set(gca,'FontName','Helvetica')

set([hTitle, hXLabel, hYLabel, hLegend], 'FontName', 'Helvetica', 'FontWeight', 'bold');
set([hLegend, gca], 'FontSize', 10);
set([hXLabel, hYLabel], 'FontSize', 12)
set(hTitle,'FontSize', 14, 'FontWeight', 'bold');
grid on
set(gca, ...
    'Box'         , 'off'     , ...
    'TickDir'     , 'out'     , ...
    'TickLength'  , [.02 .02] , ...
    'XMinorTick'  , 'on'      , ...
    'YMinorTick'  , 'on'      , ...
    'YGrid'       , 'on'      , ...
    'XColor'      , [.3 .3 .3], ...
    'YColor'      , [.3 .3 .3], ...
    'LineWidth'   , 1         );
axis fill
set(gcf, 'PaperPositionMode', 'auto');
print('-depsc2', 'task2/CLR_queues_priorityp.eps');
close;

end
